<?php
Yii::app()->clientScript->registerScriptFile($this->staticsPath."/frontend/js/jquery.js",CClientScript::POS_HEAD);
Yii::app()->clientScript->registerCssFile($this->staticsPath."/css/global.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/css/index.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/css/font-awesome.min.css");
Yii::app()->clientScript->registerCssFile($this->staticsPath."/Font-Awesome-3.2.1/css/font-awesome.min.css");

Yii::app()->clientScript->registerCss("CSS1","
    .cont_box img{
        height: 200px;
    }
    .wrap {
        margin-top: 45px;
        width: 100%;
    }
    .wrap .left{
        width:30%;
        height:60%;
        float: left;
        padding: 20px;
    }
    .wrap .left .icon-user{
        font-size:80px;
    }
    .wrap .right {
        float: right;
        height: 60%;
        padding-right: 25px;
        padding-top: 65px;
        width: 69%;
    }
    .wrap .right p{
        margin-bottom:10px;
    }
   #loadings {
        left: 50%;
        position: absolute;
        top: 50%;
    }

");


?>
<style type="text/css">
    .main-box {
        background: #FDF5E1 url("<?php echo $this->staticsPath."/img/list.png" ?>") no-repeat scroll 0 0 / 100% auto;
        height: 100%;
        left: 0;
        margin: 0 auto;
        position: absolute;
        top: 0;
        width: 100%;
        z-index: -1;
    }
    .footer{
        height: 72px;
        position: fixed;
        width: 100%;
        bottom:0;

    }

    .footer .bt{
        width: 33%;
        float: left;
        height: 100%;
    }
    .footer .bt .tj{
        background: url("<?php echo $this->staticsPath."/img/tj.png" ?>") no-repeat scroll 12px 0 / 94px auto;
        height: 100%;
        width: 100%;
    }
    .footer .bt .gr{
        background: url("<?php echo $this->staticsPath."/img/gr.png" ?>") no-repeat scroll 9px 9px / 94px auto;
        height: 100%;
        width: 100%;
    }
    .footer .bt .yd{
        background: url("<?php echo $this->staticsPath."/img/yd.png" ?>") no-repeat scroll 6px 9px / 94px auto;
        height: 100%;
        width: 100%;
    }
    body{
        background:  #F9E9BB url("<?php echo $this->staticsPath."/img/list.png" ?>") no-repeat scroll 0 0;
    }
    .wrap .book{
        width: 50%;
    }
    .book_box{
        padding: 0 20px;
    }
    .imgbox li:nth-of-type(3n) {
        margin-right: 0;
    }

    .imgbox li {
        float: left;
        margin-bottom: 11px;
        margin-left: 3px;
        margin-right: 11px;
        width: 29%;
    }
    .list_cont {
        padding: 0 1px 2px;
        position: relative;
    }

    .list_cont .list_box {
        background: #F6EBD0 none repeat scroll 0 0;
        box-shadow: 2px 2px 6px #666;
        overflow: hidden;
        position: relative;
    }
    .imgbox{
        width: 80%;
        margin: 0 auto;
    }
    .imgbox li a.img_type {
        height: 100%;
        overflow: hidden;
        width: 100%;
    }
    .imgbox li a {
        display: block;
    }

    #min .item .list_box .img_type .im {
        height: 110px;
        width: auto;
        display: block;
        margin: 0 auto;
    }
    .minwrap img, nav img {
        display: block;
        height: auto;
        margin: 0 auto;
        text-align: center;
        vertical-align: middle;
    }
    #min .item .list_box .tit {
        background: rgba(255, 255, 255, 0.8) none repeat scroll 0 0;
        bottom: 0;
        color: #0066b3;
        font-size: 10px;
        height: 22px;
        line-height: 22px;
        position: absolute;
        text-align: center;
        width: 100%;
    }
    #loading {
        font-size: 30px;
        height: 50px;
        margin: 0 auto;
        text-align: center;
        width: 100px;
    }
    .alert-error {
        color: #b94a48;
    }
    .alert {
        border-radius: 4px;
        margin-bottom: 20px;
        padding: 8px;
        text-align: center;
        text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
    }
    .header a{
        width:auto;
    }

</style>
<div class="data" >
    <div class="main-box"></div>
<!--    <header class="homeHder header">-->
<!--        <a href="--><?php //echo $this->createUrl('list',array('openid'=>$openid)) ?><!--">-->
<!--            <div class="hder_return flol">-->
<!--                <i class="size fa fa-angle-left"></i>-->
<!--            </div>-->
<!--        </a>-->
<!--        <div class="hder_logo">阅读指导</div>-->
<!--    </header>-->
    <section class="wrap">
        <ul id="min" class="imgbox clearfix">
            <?php if($list){ ?>
            <?php foreach($list as $v){ ?>
            <li class="box item">
                <div class="list_cont">
                    <div class="list_box">
                        <a class="img_type" href="<?php echo $this->createUrl('guideShow',array('id'=>$v['id'],'openid'=>$openid)) ?>">
                            <img src="<?php echo Yii::app()->params['webPath'].$v['thumb'] ?>" class="im">
                            <div class="tit">
                                <?php echo $v['title'] ?>
                            </div>
                        </a>
                    </div>
                </div>
            </li>
            <?php } ?>
            <?php }else{ ?>
            <li  style="width:100%" >
                <div class="alert alert-error">
                    暂无任何数据！
                </div>
            </li>
            <?php } ?>
        </ul>
    </section>
    <div id="loading" style="display: none"><i class="fa fa-spinner fa-spin"></i></div>
    <div id="alt" style="display: none" class="alert alert-error">
        已经到底啦！
    </div>
    <br>
    <br>
    <br>
    <br>
    <div class="footer">
        <div class="bt"><a href="<?php echo Yii::app()->createUrl('index/list',array('openid'=>$openid,'is_recommend'=>1,'is_book'=>'')) ?>"><div class="tj"></div></a></div>
        <div class="bt"><a href="<?php echo Yii::app()->createUrl('user/index',array('openid'=>$openid)); ?>"><div class="gr"></div></a></div>
        <div class="bt"><a href="<?php echo Yii::app()->createUrl('index/guide',array('openid'=>$openid)); ?>"><div class="yd"></div></a></div>

    </div>
</div>
<input type="hidden" id="is_recommend" value="<?php echo $is_recommend ?>">
<input type="hidden" id="is_book" value="<?php echo $is_book ?>">
<script type="text/javascript">
    $(function(){
        var currentPage = 0;
        var isloading = false;
        $(window).scroll(function(){
            var is_recommend = $("#is_recommend").val();
            var is_book = $("#is_book").val();
            if($(window).scrollTop() + 100 >= $(document).height() - $(window).height()){
                if (isloading == true){  //如果loading为真 则return false;
                    return false;
                }
                currentPage = currentPage + 1;
                isloading = true; //为真了
                $.ajax({
                    url:'<?php echo $this->createUrl('ajaxGuideList',array('openid'=>$openid)) ?>',
                    type : 'GET',
                    data:{
                        page:currentPage
                    },
                    dataType:'html',
                    beforeSend : function() {
                        $('#loading').show();
                        isloading = true;
                    },
                    success : function (data,response,status) {
                        if(data){
                            $('#min').append(data);
                            isloading = false;
                            $('#loading').hide();
                        }else{
                            isloading = true;
                            $('#loading').hide();
                            $('#alt').show();
                        }
                    }
                });
            }
        });
    });
</script>